<?php

/**
 * @Author: Wang chunsheng  email:2192138785@qq.com
 * @Date:   2021-06-28 14:03:10
 * @Last Modified by:   Wang chunsheng  email:2192138785@qq.com
 * @Last Modified time: 2021-06-28 14:03:20
 */


use yii\db\Migration;

class m210628_060310_website_article_category extends Migration
{
    public function up()
    {
        /* 取消外键约束 */
        $this->execute('SET foreign_key_checks = 0');

        /* 创建表 */
        $this->createTable('{{%website_article_category}}', [
            'id' => "int(10) unsigned NOT NULL AUTO_INCREMENT",
            'title' => "varchar(30) NOT NULL",
            'displayorder' => "tinyint(3) unsigned NOT NULL",
            'pcate' => "int(11) NULL DEFAULT '0'",
            'type' => "varchar(15) NOT NULL",
            'PRIMARY KEY (`id`)'
        ], "ENGINE=MyISAM  DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='文章分类'");

        /* 索引设置 */
        $this->createIndex('type', '{{%website_article_category}}', 'type', 0);


        /* 表数据 */
        $this->insert('{{%website_article_category}}', ['id' => '14', 'title' => '关于我们', 'displayorder' => '1', 'pcate' => '10', 'type' => 'about']);
        $this->insert('{{%website_article_category}}', ['id' => '8', 'title' => '智能设备', 'displayorder' => '1', 'pcate' => '10', 'type' => 'facility']);
        $this->insert('{{%website_article_category}}', ['id' => '9', 'title' => '应用场景', 'displayorder' => '1', 'pcate' => '10', 'type' => 'scene']);
        $this->insert('{{%website_article_category}}', ['id' => '10', 'title' => '网站内容', 'displayorder' => '1', 'pcate' => '0', 'type' => 'website']);
        $this->insert('{{%website_article_category}}', ['id' => '11', 'title' => '特色优势', 'displayorder' => '1', 'pcate' => '10', 'type' => 'superiority']);
        $this->insert('{{%website_article_category}}', ['id' => '12', 'title' => '开源内容', 'displayorder' => '1', 'pcate' => '10', 'type' => 'open']);
        $this->insert('{{%website_article_category}}', ['id' => '13', 'title' => '方案介绍', 'displayorder' => '1', 'pcate' => '10', 'type' => 'website1']);

        /* 设置外键约束 */
        $this->execute('SET foreign_key_checks = 1;');
    }

    public function down()
    {
        $this->execute('SET foreign_key_checks = 0');
        /* 删除表 */
        $this->dropTable('{{%website_article_category}}');
        $this->execute('SET foreign_key_checks = 1;');
    }
}
